# Potential
import math as ma

# It is not necessary to explicit the other piece of the potential (for phi<0.) because the scalar field doens't "see" it in its evolution
def pot(phi): # Expression of the potential
    if (phi>0.):
	return phi**2*(a_1*phi**2+a_2*phi+a_3)+C
    else:
	#return 2.*ma.exp(-phi**2/vel)
	return 2.*ma.cos(phi/vel_cos)**2
def dpot(phi): # First Derivative of the potential
    if (phi>0.):
	return 2.*phi*(a_1*phi**2+a_2*phi+a_3) + phi**2*(2.*a_1*phi+a_2)
    else:
	#return -4.*phi*ma.exp(-phi**2/vel)/vel
	return -2.*ma.sin(2.*phi/vel_cos)/vel_cos

def pot_FV(phi): # Expression of the potential
	return a_1*phi**4+(8.*a_1+a_2)*phi**3+(24.*a_1+6.*a_2+a_3)*phi**2+(32.*a_1+12.*a_2+4.*a_3)*phi+(16.*a_1+8.*a_2+4.*a_3+C)
def dpot_FV(phi): # First Derivative of the potential
	return 4.*a_1*phi**3+3.*(8.*a_1+a_2)*phi**2+2.*(24.*a_1+6.*a_2+a_3)*phi+(32.*a_1+12.*a_2+4.*a_3)

# DV : Difference de potentiel entre le vrai vide et le faux vide
# V_bar : Hauteur du potentiel a phi = x, par rapport a phi = 0. On ne peut pas demander que la derivee y soit nulle (le polynome doit etre de cinquieme degre)
# C : Hauteur du potentiel a phi = 0
# Dphi : Distance entre le vrai vide et le faux vide
# vel : "How far away" the slowroll part of the potential goes

# Valeurs trouvees dans l'article Johnson et al.
#DV = 0.06668
#V_bar = 0.2846
#C = 2.
#x = 1.05
#Dphi = 2.0

DV = 0.2
V_bar = 0.2846
C = 2.
x = 1.05
Dphi = 2.0

#vel = 256.
vel_cos = 1000. # Obs : phi should be << vel_cos

# a_1 = DV/(Dphi**3*(2.*(x+Dphi)/3.-Dphi)); a_2 = -4.*a_1*(x+Dphi)/3.; a_3 = -2.*a_1*(Dphi)**2 -3.*a_2*Dphi/2. # Si l'on veut que phi = x ait derivee nulle ; !!! 0<x<Dphi !!!
a_1 = (V_bar/x**2+2.*DV*(x-3.*Dphi/2.)/Dphi**3)/(x**2-2.*Dphi**2-2.*Dphi*(x-3.*Dphi/2.)); a_2 = -2.*(DV/Dphi**3+a_1*Dphi); a_3 = -2.*a_1*(Dphi)**2 -3.*a_2*Dphi/2.
